package uk.co.richardwkirk.parkrun.funnels.display.applet;
import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.GridLayout;
import java.awt.TextField;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class FunnelAppletPanel extends JPanel {

	private static final long serialVersionUID = 1L;

    private static String START_COMMAND = "start";
    
    JLabel timeLabel = null;
    
    public FunnelAppletPanel(ActionListener listener) {
        super(new BorderLayout());

        add(createSourceDataSelection(listener), BorderLayout.NORTH);
        add(createScenarioRun(listener), BorderLayout.SOUTH);
    }
    
    
    private JPanel createSourceDataSelection(ActionListener listener) {
    	// Create a sub-panel
    	JPanel panel = new JPanel(new GridLayout(2, 2));
    	panel.add(new JLabel("Parkrun"));
    	panel.add(new TextField());
    	panel.add(new JLabel("Event"));
    	panel.add(new Choice());
    	return panel;
    }

	private JPanel createScenarioRun(ActionListener listener) {
        // Show the current model time
        timeLabel = new JLabel("00:00");
        
        //Create the components.
        JButton addButton = new JButton("Start");
        addButton.setActionCommand(START_COMMAND);
        addButton.addActionListener(listener);
        
        JPanel panel = new JPanel(new GridLayout(1,1));
        panel.add(timeLabel);
        panel.add(addButton);
        return panel;
	}

	public void showTime(String time) {
		timeLabel.setText(time);
	}

}